import useCRUD from '@/hooks/useCRUD';
import { createContext, useContext } from 'react';

const CRUDContext = createContext({
  data: [],
  deleteItem: (id: any) => {
    console.log(id);
  },
  filters: (value: any) => {
    console.log(value);
  },
  resetForm: () => {},
});

export const CRUDProvider = ({ url, children }: any) => {
  const crud = useCRUD(url);
  return <CRUDContext.Provider value={crud}>{children}</CRUDContext.Provider>;
};

export const UseCRUDContext = () => {
  return useContext(CRUDContext);
};
